Olaf and Robert improve help output. Add v3 format, min/max, provide defaults, data...
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 31 Oct 2005 21:26:33 +0000 (21:26 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 31 Oct 2005 21:26:33 +0000 (21:26 +0000)
21 files changed:
gpsbabel/bcr.c
gpsbabel/compegps.c
gpsbabel/defs.h
gpsbabel/garmin.c
gpsbabel/gdb.c
gpsbabel/gpx.c
gpsbabel/ignrando.c
gpsbabel/mapsource.c
gpsbabel/nmn4.c
gpsbabel/overlay.c
gpsbabel/ozi.c
gpsbabel/pathaway.c
gpsbabel/position.c
gpsbabel/psitrex.c
gpsbabel/shape.c
gpsbabel/smplrout.c
gpsbabel/stackfilter.c
gpsbabel/stmwpp.c
gpsbabel/tiger.c
gpsbabel/vecs.c
gpsbabel/xcsv.c

index 302cfca3ada531056ec2a3dae4b6145446ec214e..702ea814c2f273f9a801c85dd0ed59f0c8eb437f 100644 (file)
@@ -58,7 +58,7 @@ static char *radius_opt;
 
 static
 arglist_t bcr_args[] = {
-       {"index", &rtenum_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT },
+       {"index", &rtenum_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL },
        {"name", &rtename_opt, "New name for the route", NULL, ARGTYPE_STRING },
        {"radius", &radius_opt, "Radius of our big earth (default 6371000 meters)", NULL, ARGTYPE_FLOAT },
        {0, 0, 0, 0, 0}
index 40704f992410c79772d8e9d7e82730125f5cc6f4..ba20227ad39dff976215b0111e1410fd8ad09e3f 100644 (file)
@@ -91,11 +91,11 @@ arglist_t compegps_args[] = {
        {"deficon", &option_icon, "Default icon name", 
                NULL, ARGTYPE_STRING},
        {"index", &option_index, "Index of route/track to write (if more the one in source)", 
-               NULL, ARGTYPE_INT},
+               NULL, ARGTYPE_INT, "1", NULL},
        {"radius", &option_radius, "Give points (waypoints/route points) a default radius (proximity)", 
-               NULL, ARGTYPE_FLOAT},
+               NULL, ARGTYPE_FLOAT, "0", NULL},
        {"snlen", &option_snlen, "Length of generated shortnames (default 16)", 
-               NULL, ARGTYPE_INT},
+               "16", ARGTYPE_INT, "1", NULL},
        {0, 0, 0, 0, 0}
 };
 
index 05b6639669459a3d91ebbfe6f336e12f8998a0a2..97b47b13257c1c0cdcf2cb5333cb04be424d25c0 100644 (file)
@@ -470,7 +470,9 @@ typedef struct arglist {
        char **argval;
        char *helpstring;
        char *defaultvalue;
-       long argtype;
+       gbuint32 argtype;
+       char *minvalue;         /* minimum value for numeric options */
+       char *maxvalue;         /* maximum value for numeric options */
 } arglist_t;
 
 typedef enum {
index 184b37c32a107db36388aa55ecfe349bbff8205a..8899af72162bc594ee6f020308f4b7bf2dd18a1e 100644 (file)
@@ -43,7 +43,7 @@ static char valid_waypt_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789";
 static
 arglist_t garmin_args[] = {
        { "snlen", &snlen, "Length of generated shortnames", NULL, 
-               ARGTYPE_INT },
+               ARGTYPE_INT, "1", NULL },
        { "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames",
                NULL, ARGTYPE_BOOL},
        { "deficon", &deficon, "Default icon name", NULL, ARGTYPE_STRING },
index 4121f2b8a65e8871e1cf431e96416a0a7aa1e0e2..5359a39f1a39d97c5a45c49ed34460b9305b7903 100644 (file)
@@ -94,9 +94,9 @@ static char *gdb_opt_via = NULL;
 
 static arglist_t gdb_args[] = {
        {GDB_OPT_CATEGORY, &gdb_opt_category, 
-           "Default category on output (1..16)", NULL, ARGTYPE_INT},
+           "Default category on output (1..16)", NULL, ARGTYPE_INT, "1", "16"},
        {GDB_OPT_VER, &gdb_opt_ver, 
-           "Version of gdb file to generate (1,2)", "2", ARGTYPE_INT},
+           "Version of gdb file to generate (1,2)", "2", ARGTYPE_INT, "1", "2"},
        {GDB_OPT_VIA, &gdb_opt_via, 
            "Drop route points, if they don't have an aquivalent waypoint (hidden points)", NULL, ARGTYPE_BOOL},
        {0, 0, 0, 0, 0}
index d4485969a2a2647004f9ab34f0a53de457c1af78..4e7c841f25119e82aedefd8778f252163f3c6142 100644 (file)
@@ -1435,10 +1435,7 @@ gpx_write(void)
        
         now = current_time();
 
-       if (snlen)
-               short_length = atoi(snlen);
-       else
-               short_length = 32;
+       short_length = atoi(snlen);
 
        if (suppresswhite) {
                setshort_whitespace_ok(mkshort_handle, 0);
@@ -1495,7 +1492,7 @@ gpx_exit(void)
 static
 arglist_t gpx_args[] = {
        { "snlen", &snlen, "Length of generated shortnames", 
-               NULL, ARGTYPE_INT },
+               "32", ARGTYPE_INT, "1", NULL },
        { "suppresswhite", &suppresswhite, 
                "Suppress whitespace in generated shortnames", 
                NULL, ARGTYPE_BOOL },
index 152f3ba7ec9c6d28a0bf0426c37b40028898cab6..4320be4335594173fd7be9cd5c1c3a0559fe0740 100644 (file)
@@ -48,7 +48,7 @@ static char *index_opt = NULL;
 
 static arglist_t ignr_args[] = 
 {
-       {"index", &index_opt, "Index of track to write (if more the one in source)", NULL, ARGTYPE_INT },
+       {"index", &index_opt, "Index of track to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL },
        {0, 0, 0, 0 }
 };
 
index 200efe710b18d430e3608cfc83ad5e36395157b6..a029285ca9f24b98f3ce9deb54ab67cd24d7b115 100644 (file)
@@ -74,7 +74,7 @@ char *mpsuseprox = NULL;
 
 static
 arglist_t mps_args[] = {
-       {"snlen", &snlen, "Length of generated shortnames", NULL, ARGTYPE_INT },
+       {"snlen", &snlen, "Length of generated shortnames", "10", ARGTYPE_INT, "1", NULL },
        { "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames",
                NULL, ARGTYPE_BOOL},
        {"mpsverout", &mpsverout, 
@@ -1916,10 +1916,7 @@ mps_write(void)
 
        unsigned char   copybuf[8192];
 
-       if (snlen)
-               short_length = atoi(snlen);
-       else
-               short_length = 10;
+       short_length = atoi(snlen);
 
        if (mpsmergeout) {
                /* need to skip over the merging header and test merge version */
index c80f6df9c656358cdd7dfee77c40b45d1fe2f5af..08db1b4ac17ac5da269ed3e4efcd77c581676aea 100644 (file)
@@ -45,7 +45,7 @@ static char *index_opt;
 
 static
 arglist_t nmn4_args[] = {
-       {"index", &index_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT },
+       {"index", &index_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL },
        {0, 0, 0, 0, 0}
 };
 
index c462077b4708d1f0ac698aeb97d02241695b7956..95d0e6f7debfac3a6d16f6dc0030d765e6085a6f 100644 (file)
@@ -78,9 +78,9 @@ static char *govl_file_s = NULL;
 
 static arglist_t ovl_args[] = {
        { "col", &govl_col_s, "color index [1-9] for routes",
-        NULL, ARGTYPE_INT },
+        NULL, ARGTYPE_INT, "1", "9" },
        { "size", &govl_size_s, "size index [101-] for routes",
-        NULL, ARGTYPE_INT },
+        NULL, ARGTYPE_INT, "101", NULL },
        { "mapname", &govl_mapname, "name of map",
         NULL, ARGTYPE_STRING },
        { "zoomfc", &govl_zoomfc_s, "zoom factor of map in %",
@@ -88,11 +88,11 @@ static arglist_t ovl_args[] = {
        { "dimmfc", &govl_dimmfc_s, "dimmer factor of map in %",
         NULL, ARGTYPE_INT },
        { "txtcol", &govl_txtcol_s, "color index [1-9] for waypoint names",
-        NULL, ARGTYPE_INT },
+        NULL, ARGTYPE_INT, "1", "9" },
        { "txtsize", &govl_txtsize_s, "text size [101-] for waypoint names",
-        NULL, ARGTYPE_INT },
+        NULL, ARGTYPE_INT, "101", NULL },
        { "font", &govl_font_s, "font index [1-] for waypoint names",
-        NULL, ARGTYPE_INT },
+        NULL, ARGTYPE_INT, "1", NULL },
        { "txttrans", &govl_txttrans_s, "set text background to transparent",
         NULL, ARGTYPE_BOOL },
        { "file", &govl_file_s, "use file of parameters (parameters on command line overwrites file parameters)",
index b35cbb40c1a7e5bbdc09689d463b6467c854445d..ce48e8f6ebe6428df30c747563e72a7a617df13f 100644 (file)
@@ -48,7 +48,7 @@ static char *snuniqueopt = NULL;
 static
 arglist_t ozi_args[] = {
        {"snlen", &snlenopt, "Max synthesized shortname length",
-               NULL, ARGTYPE_INT},
+               "32", ARGTYPE_INT, "1", NULL},
        {"snwhite", &snwhiteopt, "Allow whitespace synth. shortnames",
                NULL, ARGTYPE_BOOL},
        {"snupper", &snupperopt, "UPPERCASE synth. shortnames",
@@ -286,10 +286,7 @@ wr_init(const char *fname)
     /* set mkshort options from the command line if applicable */
     if (global_opts.synthesize_shortnames) {
 
-        if (snlenopt)
-            setshort_length(mkshort_handle, atoi(snlenopt));
-        else 
-            setshort_length(mkshort_handle, 32);
+        setshort_length(mkshort_handle, atoi(snlenopt));
 
         if (snwhiteopt)
             setshort_whitespace_ok(mkshort_handle, atoi(snwhiteopt));
index 0f9f559cbda337151038bbe48ba68be2fb2d9567..0f28469893fb827d5ee9580fd21fb6dec8856286 100644 (file)
@@ -65,7 +65,7 @@ static arglist_t ppdb_args[] =
 {
        {"dbname", &dbname, "Database name", NULL, ARGTYPE_STRING},
        {"deficon", &deficon, "Default icon name", NULL, ARGTYPE_STRING},
-       {"snlen", &snlen_opt, "Length of generated shortnames", NULL, ARGTYPE_INT },
+       {"snlen", &snlen_opt, "Length of generated shortnames", "10", ARGTYPE_INT, "1", NULL },
        {0, 0, 0, 0, 0 }
 };
 
@@ -509,10 +509,7 @@ static void ppdb_wr_init(const char *fname)
        
        if (global_opts.synthesize_shortnames != 0)
        {
-           if (snlen_opt != NULL)
-               len = atoi(snlen_opt);
-           else
-               len = 10;
+           len = atoi(snlen_opt);
            setshort_length(mkshort_handle, len);
            setshort_mustupper(mkshort_handle, 1);
            setshort_badchars(mkshort_handle, ",");
index 261708c7a2a62f11a6c4def1e0bd4a2db22201cb..72a7ef299d3f9a981f99c67634dde6c698250f9d 100644 (file)
@@ -67,7 +67,7 @@ arglist_t radius_args[] = {
        {"nosort", &nosort,    "Inhibit sort by distance to center.",
                NULL, ARGTYPE_BOOL },
        {"maxcount", &maxctarg,"Output no more than this number of points",
-               NULL, ARGTYPE_INT },
+               NULL, ARGTYPE_INT, "1", NULL },
        {0, 0, 0, 0, 0}
 };
 
index 79bc631bf0a03be4a1adf97ff8ac3607950cbe32..bd0aa8b3cf7710a5cc4a75ec7c85482c69e4c4ac 100755 (executable)
@@ -57,7 +57,7 @@ char *snlen;
 static
 arglist_t psit_args[] = {
 /*     {"snlen", &snlen, "Length of generated shortnames", 
-       NULL, ARGTYPE_INT }, */
+       NULL, ARGTYPE_INT, "1", NULL }, */
        {0, 0, 0, 0, 0}
 };
 
index e4deb52c271616d888a15802263c45e872b08d50..607f62ed5f8468ea7de114b9516adc67a2547414 100644 (file)
@@ -39,7 +39,7 @@ static char *opt_name = NULL;
 static
 arglist_t shp_args[] = {
        {"name", &opt_name, "Index of name field in .dbf",
-               NULL, ARGTYPE_INT },
+               NULL, ARGTYPE_INT, "0", NULL },
        { 0, 0, 0, 0}
 };
 
index 7688582dccd8e5b8c2739104ab201575aec2998c..9659c80db46008509a9d7717fe4c5ffeb47840ab 100644 (file)
@@ -30,7 +30,7 @@ static char *countopt = NULL;
 static
 arglist_t routesimple_args[] = {
        {"count", &countopt,  "Maximum number of points in route", 
-               NULL, ARGTYPE_INT | ARGTYPE_REQUIRED},
+               NULL, ARGTYPE_INT | ARGTYPE_REQUIRED, "1", NULL},
        {0, 0, 0, 0, 0}
 };
 
index 38bfd4854c50bd6e728f92f9e1391e8c612cc839..6f973292f125d96de846dc25e000e1d2b97aea3c 100644 (file)
@@ -53,7 +53,7 @@ arglist_t stackfilt_args[] = {
        {"replace", &opt_replace, "(pop) Replace list (default)", 
                NULL, ARGTYPE_END_EXCL | ARGTYPE_BOOL},
        {"depth", &opt_depth, "(swap) Item to use (default=1)", 
-               NULL, ARGTYPE_INT},
+               NULL, ARGTYPE_INT, "0", NULL},
        {"nowarn", &nowarn, "Suppress cleanup warning", NULL, 
                ARGTYPE_BOOL | ARGTYPE_HIDDEN},
        {0, 0, 0, 0, 0}
index 1abd3cf7dc5b8397d88f52b4e36d6e448356b0f7..638ee4adf866e9e86571c0d7c16b18d935789e82 100644 (file)
@@ -46,7 +46,8 @@ static char *index_opt = NULL;
 static
 arglist_t stmwpp_args[] = 
 {
-       {"index", &index_opt, "Index of route/track to write (if more the one in source)", NULL, ARGTYPE_INT },
+       {"index", &index_opt, "Index of route/track to write (if more the one in source)", 
+               NULL, ARGTYPE_INT, "1", NULL },
        {0, 0, 0, 0, 0}
 };
 
index 52c09157eadf8e260a68413c2e67bca4e856156f..50b3a70bc8279e1f1a4d9db02a26f53a4cb31be2 100644 (file)
@@ -69,7 +69,7 @@ arglist_t tiger_args[] = {
        {"margin", &margin, "Margin for map.  Degrees or percentage.",
                "15%", ARGTYPE_FLOAT},
        {"snlen", &snlen, "Max shortname length when used with -s.",
-               NULL, ARGTYPE_INT},
+               "10", ARGTYPE_INT, "1", NULL},
        {"oldthresh", &oldthresh, 
                "Days after which points are considered old.",
                "14", ARGTYPE_INT},
@@ -228,10 +228,7 @@ data_write(void)
        minlon = 9999.0;
        rec_cnt = 0;
 
-       if (snlen)
-               short_length = atoi(snlen);
-       else
-               short_length = 10;
+       short_length = atoi(snlen);
        mkshort_whandle = mkshort_new_handle();
 
        if (suppresswhite) {
index 03b7c5ae74a3e561aa9175bc901b6ecff7de9f64..7b5c6c08d3b05f2201584e5b2d924bb415eb3be6 100644 (file)
@@ -783,6 +783,43 @@ disp_v2(ff_vecs_t *v)
        putchar('\t');
 }
 
+const char *
+name_option(long type)
+{
+       const char *at[] = {
+               "unknown",
+               "integer",
+               "float",
+               "string",
+               "boolean",
+               "file",
+               "outfile"
+       };
+
+       if ((type & ARGTYPE_TYPEMASK) <= 6) {
+               return at[type & ARGTYPE_TYPEMASK];
+       }
+       return at[0];
+}
+
+static void 
+disp_v3(vecs_t *vec)
+{
+       arglist_t *ap;
+
+       for (ap = vec->vec->args; ap && ap->argstring; ap++) {
+               if ( !(ap->argtype & ARGTYPE_HIDDEN))
+                       printf("option\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
+                       vec->name, 
+                       ap->argstring, 
+                       ap->helpstring, 
+                       name_option(ap->argtype),
+                       ap->defaultvalue? ap->defaultvalue : "",
+                       ap->minvalue? ap->minvalue : "",
+                       ap->maxvalue? ap->maxvalue : "");
+       }
+}
+
 /*
  *  Display the available formats in a format that's easy to machine
  *  parse.   Typically invoked by programs like graphical wrappers to
@@ -799,6 +836,7 @@ disp_formats(int version)
        case 0:
        case 1:
        case 2:
+       case 3:
                svp = sort_and_unify_vecs(&vc);
                for (i=0;i<vc;i++,vec++) {
                        vec = svp[i];
@@ -818,6 +856,9 @@ disp_formats(int version)
                        printf("%s\t%s\t%s\n", vec->name, 
                                vec->extension? vec->extension : "", 
                                vec->desc);
+                       if (version >= 3) {
+                               disp_v3(vec);
+                       }
                }
                xfree (svp);    
                break;
index 5cff74c769022d61649a2d859da2240e9ccc5932..bbcffd75ebc990b0e8b061331b506cf76677a3ed 100644 (file)
@@ -45,7 +45,7 @@ arglist_t xcsv_args[] = {
        {"style", &styleopt, "Full path to XCSV style file", NULL,
                ARGTYPE_FILE | ARGTYPE_REQUIRED },
        {"snlen", &snlenopt, "Max synthesized shortname length", NULL,
-               ARGTYPE_INT},
+               ARGTYPE_INT, "1", NULL},
        {"snwhite", &snwhiteopt, "Allow whitespace synth. shortnames",
                NULL, ARGTYPE_BOOL},
        {"snupper", &snupperopt, "UPPERCASE synth. shortnames",